/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Logon.java
 *
 * Created on 2011-6-23, 10:26:02
 */
package seso;

import org.jdesktop.application.Action;

/**
 *
 * @author Administrator
 */
public class Logon extends javax.swing.JFrame {

    /** Creates new form Logon */
    public Logon() {
        initComponents();
        setIconImage(Util.getLogoImage());

        //setLocationRelativeTo(null);
        setScreenCenter(jLabelBackground.getWidth(), jLabelBackground.getHeight());
        
        getRootPane().setDefaultButton(cmdLogOn);
    }

    
    private void setScreenCenter(int width, int height) {
        setSize(width, height);
        setPreferredSize(new java.awt.Dimension(width, height));
        setLocationRelativeTo(null);
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cmdLogOn = new seso.RBgButton();
        cmdLogCancel = new seso.RBgButton();
        userNameFld = new seso.RTextField();
        passwordFld = new seso.RPasswordField();
        jLabelBackground = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(seso.SesoApp.class).getContext().getResourceMap(Logon.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setLocationByPlatform(true);
        setName("Form"); // NOI18N
        setResizable(false);
        setUndecorated(true);
        getContentPane().setLayout(null);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(seso.SesoApp.class).getContext().getActionMap(Logon.class, this);
        cmdLogOn.setAction(actionMap.get("cmdLogOnAction")); // NOI18N
        cmdLogOn.setIcon(resourceMap.getIcon("cmdLogOn.icon")); // NOI18N
        cmdLogOn.setText(resourceMap.getString("cmdLogOn.text")); // NOI18N
        cmdLogOn.setName("cmdLogOn"); // NOI18N
        cmdLogOn.setPressedIcon(resourceMap.getIcon("cmdLogOn.pressedIcon")); // NOI18N
        cmdLogOn.setRolloverIcon(resourceMap.getIcon("cmdLogOn.rolloverIcon")); // NOI18N
        cmdLogOn.setSelectedIcon(resourceMap.getIcon("cmdLogOn.selectedIcon")); // NOI18N
        getContentPane().add(cmdLogOn);
        cmdLogOn.setBounds(243, 398, 120, 29);

        cmdLogCancel.setAction(actionMap.get("cmdLogCancelAction")); // NOI18N
        cmdLogCancel.setIcon(resourceMap.getIcon("cmdLogCancel.icon")); // NOI18N
        cmdLogCancel.setText(resourceMap.getString("cmdLogCancel.text")); // NOI18N
        cmdLogCancel.setName("cmdLogCancel"); // NOI18N
        cmdLogCancel.setPressedIcon(resourceMap.getIcon("cmdLogCancel.pressedIcon")); // NOI18N
        cmdLogCancel.setRolloverIcon(resourceMap.getIcon("cmdLogCancel.rolloverIcon")); // NOI18N
        cmdLogCancel.setSelectedIcon(resourceMap.getIcon("cmdLogCancel.selectedIcon")); // NOI18N
        getContentPane().add(cmdLogCancel);
        cmdLogCancel.setBounds(363, 398, 120, 29);

        userNameFld.setText(resourceMap.getString("userNameFld.text")); // NOI18N
        userNameFld.setName("userNameFld"); // NOI18N
        getContentPane().add(userNameFld);
        userNameFld.setBounds(171, 368, 152, 26);

        passwordFld.setText(resourceMap.getString("passwordFld.text")); // NOI18N
        passwordFld.setName("passwordFld"); // NOI18N
        getContentPane().add(passwordFld);
        passwordFld.setBounds(328, 368, 152, 26);

        jLabelBackground.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelBackground.setIcon(resourceMap.getIcon("jLabelBackground.icon")); // NOI18N
        jLabelBackground.setText(resourceMap.getString("jLabelBackground.text")); // NOI18N
        jLabelBackground.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jLabelBackground.setName("jLabelBackground"); // NOI18N
        getContentPane().add(jLabelBackground);
        jLabelBackground.setBounds(0, 0, 503, 446);

        getAccessibleContext().setAccessibleName(resourceMap.getString("Form.AccessibleContext.accessibleName")); // NOI18N

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Logon().setVisible(true);
            }
        });
    }

    @Action
    public void cmdLogOnAction() {
        SelectProfile form = new SelectProfile(userNameFld.getText());
        form.setLocationRelativeTo(null);
        dispose();
        SesoApp.getApplication().show(form);        
        
        /*
        HomePage form = new HomePage();
        form.setLocationRelativeTo(null);
        dispose();
        SesoApp.getApplication().show(form);
         * 
         */
    }

    @Action
    public void cmdLogCancelAction() {
        dispose();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private seso.RBgButton cmdLogCancel;
    private seso.RBgButton cmdLogOn;
    private javax.swing.JLabel jLabelBackground;
    private seso.RPasswordField passwordFld;
    private seso.RTextField userNameFld;
    // End of variables declaration//GEN-END:variables
}
